package com.whstudio.chat;

import java.util.ArrayDeque;

import com.whstudio.common.pattern.MessageStackable;
import com.whstudio.common.pattern.Observable;
import com.whstudio.common.pattern.Subscriber;

/**
 * 聊天用户
 * @author wbwanggp
 *
 */
public abstract class AbstractChatUser implements Subscriber,MessageStackable {
	private ArrayDeque<String> msgQueue=new ArrayDeque<String>();
	
	public String getMessage(){
		if(msgQueue.isEmpty()){
			return "";
		}
		return msgQueue.remove();
	}

	/**
	 * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
	 */
	@Override
	public void update(Observable o, Object arg) {
		msgQueue.add(String.valueOf(arg));
	}

}
